package router

import (
	"hr/api/middleware"
	v1 "hr/api/v1"
	"hr/config"

	"github.com/gin-gonic/gin"
)

func initV1Router(r *gin.Engine) {
	r.Use(middleware.CorsMiddleware())

	r.NoRoute(v1.NoFound)
	group := r.Group(config.AppConfig.App.ApiPrefix)
	{
		v1Group := group.Group("/v1")
		noauthGroup := group.Group("/v1/noauth")
		// 静态资源路径
		v1Group.Static(config.AppConfig.Static.StaticPath, config.AppConfig.Static.StaticDir)
		{
			v1Group.GET("", v1.V1)
			// 公共
			commonGroup := v1Group.Group("/common")
			{
				commonGroup.POST("/uploadFile", v1.UploadFile)
			}
			// 账号相关
			accountGroup := v1Group.Group("/account")
			{
				accountGroup.POST("/login", v1.Login)
				accountGroup.POST("/register", v1.Register)
				accountGroup.POST("/mail", v1.SendMailCode)
				accountGroup.POST("/updatePassword", v1.UpdatePassword)
				accountGroup.POST("/forgetPassword", v1.ForgetPassword)
			}
			authGroup := v1Group.Group("/auth", middleware.RegisterJwtAuth())
			{
				authGroup.POST("/logout", v1.Logout)
				authGroup.GET("/info", v1.GetUserInfo)
				dictGroup := authGroup.Group("/dict")
				{
					dictGroup.GET("", v1.GetDict)
					dictGroup.GET("/:key", v1.GetDictByKey)
					dictGroup.POST("", v1.CreateDict)
					dictGroup.PUT("/:id", v1.UpdateDict)
					dictGroup.DELETE("/:id", v1.DeleteDict)
				}
				dictValueGroup := authGroup.Group("/dictValue")
				{
					dictValueGroup.GET("/:dictId", v1.GetDictValue)
					dictValueGroup.POST("/:dictId", v1.CreateDictValue)
					dictValueGroup.PUT("/:id", v1.UpdateDictValue)
					dictValueGroup.DELETE("/:id", v1.DeleteDictValue)
				}
				menuGroup := authGroup.Group("/menu")
				{
					menuGroup.GET("", v1.GetMenu)
					menuGroup.POST("", v1.CreateMenu)
					menuGroup.PUT("/:id", v1.UpdateMenu)
					menuGroup.DELETE("/:id", v1.DeleteMenu)
				}

				roleGroup := authGroup.Group("/role")
				{
					roleGroup.GET("", v1.GetRole)
					roleGroup.POST("", v1.CreateRole)
					roleGroup.PUT("/:id", v1.UpdateRole)
					roleGroup.DELETE("/:id", v1.DeleteRole)
				}

				userGroup := authGroup.Group("/user")
				{
					userGroup.GET("", v1.GetUser)
					userGroup.GET("/getUserByDeptId", v1.GetUserByDeptId)
					userGroup.GET("/getUserByDept", v1.GetUserByDept)
					userGroup.POST("", v1.CreateUser)
					userGroup.PUT("/:id", v1.UpdateUser)
					userGroup.DELETE("/:id", v1.DeleteUser)
				}

				deptGroup := authGroup.Group("/dept")
				{
					deptGroup.GET("", v1.GetDept)
					deptGroup.POST("", v1.CreateDept)
					deptGroup.PUT("/:id", v1.UpdateDept)
					deptGroup.DELETE("/:id", v1.DeleteDept)
				}

				postGroup := authGroup.Group("/post")
				{
					postGroup.GET("", v1.GetPost)
					postGroup.POST("", v1.CreatePost)
					postGroup.PUT("/:id", v1.UpdatePost)
					postGroup.DELETE("/:id", v1.DeletePost)
				}

				// 服装申请
				clothingGroup := authGroup.Group("/clothing")
				{
					clothingGroup.GET("", v1.GetClothingApproval)
					clothingGroup.POST("", v1.CreateClothingApproval)
					clothingGroup.PUT("/:id", v1.UpdateClothingApproval)
					clothingGroup.DELETE("/:id", v1.DeleteClothingApproval)
					clothingGroup.POST("/order_status/:id/:order_status", v1.UpdateClothingApprovalOrderStatus)
					clothingGroup.POST("/approval_status/:id", v1.UpdateClothingApprovalApprovalStatus)
				}

				// 费用申报
				ExpenseDeclarationApprovalGroup := authGroup.Group("/expense_declaration_approval")
				{
					ExpenseDeclarationApprovalGroup.GET("", v1.GetExpenseDeclarationApproval)
					ExpenseDeclarationApprovalGroup.POST("", v1.CreateExpenseDeclarationApproval)
					ExpenseDeclarationApprovalGroup.PUT("/:id", v1.UpdateExpenseDeclarationApproval)
					ExpenseDeclarationApprovalGroup.DELETE("/:id", v1.DeleteExpenseDeclarationApproval)
					ExpenseDeclarationApprovalGroup.POST("/order_status/:id/:order_status", v1.UpdateExpenseDeclarationApprovalOrderStatus)
					ExpenseDeclarationApprovalGroup.POST("/approval_status/:id", v1.UpdateExpenseDeclarationApprovalApprovalStatus)
				}

				// 转正申请
				FormalApprovalGroup := authGroup.Group("/approval_formal")
				{
					FormalApprovalGroup.GET("", v1.GetFormalApproval)
					FormalApprovalGroup.POST("", v1.CreateFormalApproval)
					FormalApprovalGroup.PUT("/:id", v1.UpdateFormalApproval)
					FormalApprovalGroup.DELETE("/:id", v1.DeleteFormalApproval)
					FormalApprovalGroup.POST("/order_status/:id/:order_status", v1.UpdateFormalApprovalOrderStatus)
					FormalApprovalGroup.POST("/approval_status/:id", v1.UpdateFormalApprovalApprovalStatus)
				}
				// 保险缴费申请
				InsureApprovalGroup := authGroup.Group("/insure_approval")
				{
					InsureApprovalGroup.GET("", v1.GetInsureApproval)
					InsureApprovalGroup.POST("", v1.CreateInsureApproval)
					InsureApprovalGroup.PUT("/:id", v1.UpdateInsureApproval)
					InsureApprovalGroup.DELETE("/:id", v1.DeleteInsureApproval)
					InsureApprovalGroup.POST("/order_status/:id/:order_status", v1.UpdateInsureApprovalOrderStatus)
					InsureApprovalGroup.POST("/approval_status/:id", v1.UpdateInsureApprovalApprovalStatus)
				}
				// 保险断缴申请
				NoInsureApprovalGroup := authGroup.Group("/no_insure_approval")
				{
					NoInsureApprovalGroup.GET("", v1.GetNoInsureApproval)
					NoInsureApprovalGroup.POST("", v1.CreateNoInsureApproval)
					NoInsureApprovalGroup.PUT("/:id", v1.UpdateNoInsureApproval)
					NoInsureApprovalGroup.DELETE("/:id", v1.DeleteNoInsureApproval)
					NoInsureApprovalGroup.POST("/order_status/:id/:order_status", v1.UpdateNoInsureApprovalOrderStatus)
					NoInsureApprovalGroup.POST("/approval_status/:id", v1.UpdateNoInsureApprovalApprovalStatus)
				}
				// 公章申请
				OfficialSealApprovalGroup := authGroup.Group("/official_seal_approval")
				{
					OfficialSealApprovalGroup.GET("", v1.GetOfficialSealApproval)
					OfficialSealApprovalGroup.POST("", v1.CreateOfficialSealApproval)
					OfficialSealApprovalGroup.PUT("/:id", v1.UpdateOfficialSealApproval)
					OfficialSealApprovalGroup.DELETE("/:id", v1.DeleteOfficialSealApproval)
					OfficialSealApprovalGroup.POST("/order_status/:id/:order_status", v1.UpdateOfficialSealApprovalOrderStatus)
					OfficialSealApprovalGroup.POST("/approval_status/:id", v1.UpdateOfficialSealApprovalApprovalStatus)
				}
				// 调岗申请
				PostTransferApprovalGroup := authGroup.Group("/approval_post_transfer")
				{
					PostTransferApprovalGroup.GET("", v1.GetPostTransferApproval)
					PostTransferApprovalGroup.POST("", v1.CreatePostTransferApproval)
					PostTransferApprovalGroup.PUT("/:id", v1.UpdatePostTransferApproval)
					PostTransferApprovalGroup.DELETE("/:id", v1.DeletePostTransferApproval)
					PostTransferApprovalGroup.POST("/order_status/:id/:order_status", v1.UpdatePostTransferApprovalOrderStatus)
					PostTransferApprovalGroup.POST("/approval_status/:id", v1.UpdatePostTransferApprovalApprovalStatus)
				}
				// 离职申请
				QuitApprovalGroup := authGroup.Group("/approval_quit")
				{
					QuitApprovalGroup.GET("", v1.GetQuitApproval)
					QuitApprovalGroup.POST("", v1.CreateQuitApproval)
					QuitApprovalGroup.PUT("/:id", v1.UpdateQuitApproval)
					QuitApprovalGroup.DELETE("/:id", v1.DeleteQuitApproval)
					QuitApprovalGroup.POST("/order_status/:id/:order_status", v1.UpdateQuitApprovalOrderStatus)
					QuitApprovalGroup.POST("/approval_status/:id", v1.UpdateQuitApprovalApprovalStatus)
				}
				// 加班申请
				WorkOvertimeApprovalGroup := authGroup.Group("/approval_work_overtime")
				{
					WorkOvertimeApprovalGroup.GET("", v1.GetWorkOvertimeApproval)
					WorkOvertimeApprovalGroup.POST("", v1.CreateWorkOvertimeApproval)
					WorkOvertimeApprovalGroup.PUT("/:id", v1.UpdateWorkOvertimeApproval)
					WorkOvertimeApprovalGroup.DELETE("/:id", v1.DeleteWorkOvertimeApproval)
					WorkOvertimeApprovalGroup.POST("/order_status/:id/:order_status", v1.UpdateWorkOvertimeApprovalOrderStatus)
					WorkOvertimeApprovalGroup.POST("/approval_status/:id", v1.UpdateWorkOvertimeApprovalApprovalStatus)
				}

				ApprovalRecordGroup := authGroup.Group("/approval_record")
				{
					ApprovalRecordGroup.GET("", v1.GetApprovalRecord)
				}
				// 考勤管理
				AttendanceGroup := authGroup.Group("/attendance")
				{
					AttendanceGroup.GET("/export", v1.ExportExcel)
					AttendanceGroup.GET("/all", v1.GetAttendanceAll)
					AttendanceGroup.GET("/user", v1.GetAttendanceUser)
					AttendanceGroup.POST("/submit", v1.AttendanceSubmit)

				}
				// 档案管理
				archivesGroup := authGroup.Group("/archives")
				{
					archivesGroup.GET("", v1.GetArchives)
					archivesGroup.POST("", v1.CreateArchives)
					archivesGroup.PUT("/:id", v1.UpdateArchives)
					archivesGroup.DELETE("/:id", v1.DeleteArchives)
				}
				// 招聘管理
				recruitmentGroup := authGroup.Group("/recruitment")
				{
					noauthGroup.GET("/recruitment", v1.GetRecruitment)
					recruitmentGroup.POST("", v1.CreateRecruitment)
					recruitmentGroup.PUT("/:id", v1.UpdateRecruitment)
					recruitmentGroup.DELETE("/:id", v1.DeleteRecruitment)
				}
				// 广告管理
				adGroup := authGroup.Group("/ad")
				{
					noauthGroup.GET("/ad", v1.GetAd)
					adGroup.POST("", v1.CreateAd)
					adGroup.PUT("/:id", v1.UpdateAd)
					adGroup.DELETE("/:id", v1.DeleteAd)
				}
				// 公司简介
				companyProfileGroup := authGroup.Group("/company_profile")
				{
					noauthGroup.GET("/company_profile", v1.GetCompanyProfile)
					companyProfileGroup.POST("", v1.CreateCompanyProfile)
					companyProfileGroup.PUT("/:id", v1.UpdateCompanyProfile)
					companyProfileGroup.DELETE("/:id", v1.DeleteCompanyProfile)
				}

				// 用户管理
				userManageGroup := authGroup.Group("/user_manage")
				{
					userManageGroup.GET("/getMiNiAppPaging", v1.GetMiNiAppPaging)
					v1Group.GET("/getMiNiApp", v1.GetUserManage)
					v1Group.POST("/getMiNiAppPhone", v1.GetUserPhone)
					v1Group.POST("/getMiNiAppUserInfo", v1.GetMiNiAppUserInfo)
					userManageGroup.POST("", v1.CreateUserManage)
					userManageGroup.PUT("/:id", v1.UpdateUserManage)
					userManageGroup.DELETE("/:id", v1.DeleteUserManage)
				}
				// 应聘管理
				applicationManageGroup := authGroup.Group("/application_manage")
				{
					applicationManageGroup.GET("/getPaging", v1.GetApplicationManagePaging)
					applicationManageGroup.GET("/get/:id", v1.GetApplicationManage)
					applicationManageGroup.GET("/get", v1.GetLatestApplication)
					applicationManageGroup.POST("", v1.CreateApplicationManage)
					applicationManageGroup.PUT("/:id", v1.UpdateApplicationManage)
					applicationManageGroup.DELETE("/:id", v1.DeleteApplicationManage)
				}
				inviteGroup := authGroup.Group("/invite")
				{
					inviteGroup.GET("/qrcode", v1.GetUserQrcode)
					inviteGroup.GET("/paging", v1.GetInviteManage)
					inviteGroup.GET("/user", v1.GetUserInviteManage)
					inviteGroup.POST("", v1.CreateInviteManage)
					inviteGroup.PUT("/:id/:status", v1.UpdateInviteManage)
				}
				// 宣传管理
				publicityManageGroup := authGroup.Group("/publicityManage")
				{
					publicityManageGroup.GET("", v1.GetPublicityManage)
					publicityManageGroup.POST("", v1.CreatePublicityManage)
					publicityManageGroup.PUT("/:id", v1.UpdatePublicityManage)
					publicityManageGroup.DELETE("/:id", v1.DeletePublicityManage)
				}
				// banner
				bannerGroup := authGroup.Group("/banner")
				{
					noauthGroup.GET("/banner", v1.GetBanner)
					bannerGroup.POST("", v1.CreateBanner)
					bannerGroup.PUT("/:id", v1.UpdateBanner)
					bannerGroup.DELETE("/:id", v1.DeleteBanner)
				}
				// tabs
				tabsGroup := authGroup.Group("/tabs")
				{
					noauthGroup.GET("/tabs", v1.GetTabs)
					tabsGroup.POST("", v1.CreateTabs)
					tabsGroup.PUT("/:id", v1.UpdateTabs)
					tabsGroup.DELETE("/:id", v1.DeleteTabs)
					tabsGroup.POST("/up/:id", v1.UpTabs)
					tabsGroup.POST("/down/:id", v1.DownTabs)
				}

				//薪资管理
				salaryGroup := authGroup.Group("/salary")
				{
					salaryGroup.GET("/", v1.GetSalary)
					salaryGroup.GET("/user", v1.GetSalaryByUser)
					salaryGroup.POST("/import", v1.ImportSalary)
					salaryGroup.DELETE("/:id", v1.DeleteSalary)
				}

				//系统配置
				optionsGroup := authGroup.Group("/options")
				{
					optionsGroup.GET("/", v1.GetOptions)
					optionsGroup.POST("/update", v1.UpdateOptions)
					optionsGroup.GET("/:code", v1.GetOptionsByCode)
				}
			}
		}
	}
}
